﻿@{
    Layout = null;

    if (!Kendo.Mvc.SiteMapManager.SiteMaps.ContainsKey("admin"))
    {
        Kendo.Mvc.SiteMapManager.SiteMaps.Register<Kendo.Mvc.XmlSiteMap>("admin", sitemap =>
            sitemap.LoadFrom("~/Areas/Admin/sitemap.config"));
    }
    var area = "Admin";
}
@{
    Html.Kendo().Menu().Name("AdminMenu")
    .BindTo("admin",(item,siteMapNode)=>
        {
            if (!String.IsNullOrWhiteSpace(item.ControllerName))
            {
                                    
                var areaName = siteMapNode.Attributes["area"];
                if (areaName==null || String.IsNullOrEmpty(areaName.ToString()))
                {
                    areaName = area;
                }
                item.RouteValues = new RouteValueDictionary
                {
                    {"area", areaName}
                };
            }
            var imageUrl = siteMapNode.Attributes["ImageUrl"];
            if (imageUrl !=null && !String.IsNullOrEmpty(imageUrl.ToString()))
            {
                item.ImageUrl = imageUrl.ToString();
            }
            if (ViewBag.SelectedMenuItem == item.Text)
            {
                item.Selected = true;
            }
        })
        .OpenOnClick(false).Render();
}